Use setdefault for internal cache to ensure identity caching#2217
Conversation
Switch selected cache write sites to setdefault/get-based patterns and keep explicit comments where setdefault is intentionally not used for primitive value caches. Signed-off-by: Sebastian Berg <sebastianb@nvidia.com>
e30c476 to
3497ccf
Compare
|
/ok to test 3497ccf |
|
mdboom
left a comment
There was a problem hiding this comment.
LGTM.
Do we want to add any AGENTS.md content about this pattern being preferred over functools.cache or the non-setdefault caching pattern?
Not sure However, @rwgk: When scanning for |
Switch selected cache write sites to setdefault/get-based patterns and keep explicit comments where setdefault is intentionally not used for primitive value caches.
(I just thought having
setdefaultmentioned might be nice in case of cargo-culting.)Towards gh-2194; pytest-run-parallel does have a specific test for the
GraphMemoryResourcechange. I could add an identity test forComputeCapabilityprobably (I doubt it actually matters for it, the use ofsetdefaultjust feels like a good pattern to me).